package com.wanli.storemobile.mine.model;


import com.wanli.storemobile.appconst.MethodType;
import com.wanli.storemobile.appconst.URLConst;
import com.wanli.storemobile.base.DataCallBack;
import com.wanli.storemobile.bean.BaseResponseBean;
import com.wanli.storemobile.bean.IncomeListBean;
import com.wanli.storemobile.bean.IndexMessageBean;
import com.wanli.storemobile.bean.StoreAdminBean;
import com.wanli.storemobile.bean.StoreProfileBean;
import com.wanli.storemobile.bean.UserInfoBean;
import com.wanli.storemobile.bean.WechatStateBean;
import com.wanli.storemobile.bean.WithdrawListBean;
import com.wanli.storemobile.retorfit_manager.ResponseObserver;
import com.wanli.storemobile.retorfit_manager.RetrofitHelper;
import com.wanli.storemobile.utils.ToastUtil;

import java.util.HashMap;
import java.util.Map;


public class MineModelImpl implements IMineModel {
    @Override
    public void requestMine(DataCallBack<UserInfoBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.ME, null, new ResponseObserver<UserInfoBean>() {
            @Override
            public void onSuccessful(UserInfoBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(UserInfoBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestStoreAdmin(DataCallBack<StoreAdminBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.STOREADMIN, null, new ResponseObserver<StoreAdminBean>() {
            @Override
            public void onSuccessful(StoreAdminBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(StoreAdminBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestMerchantMine(DataCallBack<UserInfoBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.MERCHANTME, null, new ResponseObserver<UserInfoBean>() {
            @Override
            public void onSuccessful(UserInfoBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(UserInfoBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestStoreWechatState(DataCallBack<WechatStateBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.queryStoreWechatState, null, new ResponseObserver<WechatStateBean>() {
            @Override
            public void onSuccessful(WechatStateBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(WechatStateBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestStoreWechatStateDianYin(DataCallBack<WechatStateBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.GetWxVerify, null, new ResponseObserver<WechatStateBean>() {
            @Override
            public void onSuccessful(WechatStateBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(WechatStateBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestUpLngLat(String lat, String lng, String lnglat, String store_no, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("lat", lat);
        params.put("lng", lng);
        params.put("lnglat", lnglat);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.upLngLat, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestIndexMessage(int page, DataCallBack<IndexMessageBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 50);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.MESSAGECENTER, params, new ResponseObserver<IndexMessageBean>() {
            @Override
            public void onSuccessful(IndexMessageBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(IndexMessageBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }


    @Override
    public void requestLoginOut(String id, DataCallBack<BaseResponseBean> callBack) {
//        Map<String, Object> params = new HashMap<>();
//        params.put("id", id);
//        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.LOGINOUT, params, new ResponseObserver<BaseResponseBean>() {
//            @Override
//            public void onSuccessful(BaseResponseBean bean, String msg) {
//                callBack.onSuccessful(bean);
//            }
//
//            @Override
//            public void onFailure(BaseResponseBean bean, String msg, String code) {
//                ToastUtil.showShort(msg);
//            }
//        });
    }

    @Override
    public void requestStoreWithdrawal(int page, String status, DataCallBack<WithdrawListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 50);
        params.put("status", status);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.StoreWithdrawal, params, new ResponseObserver<WithdrawListBean>() {
            @Override
            public void onSuccessful(WithdrawListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(WithdrawListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestStoreProfile(DataCallBack<StoreProfileBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.StoreProfile, null, new ResponseObserver<StoreProfileBean>() {
            @Override
            public void onSuccessful(StoreProfileBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(StoreProfileBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestWithdrawalAdd(String money, String type, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("money", money);
        params.put("type", type);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.StoreWithdrawalAdd, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestOrderSubsidyMoneyIndex(int page, DataCallBack<IncomeListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 50);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.OrderSubsidyMoneyIndex, params, new ResponseObserver<IncomeListBean>() {
            @Override
            public void onSuccessful(IncomeListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(IncomeListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestLogoutNew(String id, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.LOGOUTNEW, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }
}
